package org.his.service.impl;

import java.util.List;

import org.his.entity.Doctor;
import org.his.mapper.DoctorMapper;
import org.his.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DoctorServiceImpl implements DoctorService{
	@Autowired
	private DoctorMapper doctorMapper;

	public List<Doctor> queryAllDoctor() {
		return doctorMapper.queryAllDoctor();
	}

	public List<Doctor> queryByFrom(Doctor qDoctor) {
		if (qDoctor.getDoctorno() != null || qDoctor.getDoctorname() != null || qDoctor.getDepartment() != null) {
			return doctorMapper.queryByFrom(qDoctor);
		} else {
			return doctorMapper.queryAllDoctor();
		}
	}

	public Doctor queryDoctorByNo(String username) {
		
		return doctorMapper.queryDoctorByNo(username);
	}

	public int deleteDoctor(String deleteDoctorno) {
	int count = 0;
	try {
		count = doctorMapper.deleteDoctor(deleteDoctorno);
	} catch (Exception e) {
		e.printStackTrace();
		count = -1;
	}
		return count;
	}

	public int addDoctor(Doctor addDoctor) {
		int count = 0;
		try {
			count = doctorMapper.addDoctor(addDoctor);
		} catch (Exception e) {
			e.printStackTrace();
			count = -1;
		}
			return count;
		}
	
	
	
}
